package com.pug.mail.controller;

import cn.hutool.extra.mail.Mail;
import com.pug.mail.dto.MySendMailReqDTO;
import com.pug.mail.service.IMailService;
import com.pug.mail.utils.EmailSendUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xq.pug.common.result.R;

/**
 * @author RenGaoshuai
 * @date 2023/6/29 10:40
 * @description
 */
@RestController
@RequestMapping("/mail")
public class MailController {

    @Autowired
    private IMailService mailService;

    @PostMapping("/sendMail")
    public R<Boolean> testSendMail(@RequestBody MySendMailReqDTO dto){
        //发送短信
        boolean isSuccess  = mailService.sendMail(dto);
        return R.ofSuccess(isSuccess);
    }

    @PostMapping("/sendMail2")
    public R<Boolean> testSendMail2(@RequestBody MySendMailReqDTO dto){
        //发送短信
        boolean isSuccess  = mailService.sendMailAttachment(dto);
        return R.ofSuccess(isSuccess);
    }
}
